package com.jerp.ui.main;

import java.util.HashSet;
import java.util.Set;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zul.AbstractListModel;

public class MainUIModel extends AbstractListModel<VmMainUI> {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1456061735466100864L;
	private Set<VmMainUI> mainUISet = new HashSet<VmMainUI>();
	private VmMainUI selected = null;

	public Set<VmMainUI> getMainUISet() {
		return mainUISet;
	}

	public void setMainUISet(Set<VmMainUI> mainUISet) {
		this.mainUISet = mainUISet;
	}

	@GlobalCommand
	@NotifyChange("mainUISet")
	public boolean addMainUI(@BindingParam("uiDesc") UiDescriptor uiDesc) {
		return mainUISet.add(new VmMainUI(uiDesc));
	}

	@Command
	@NotifyChange("mainUISet")
	public void closeUI(@BindingParam("ui") VmMainUI mainUI) {
		mainUISet.remove(mainUI);
	}

	@Command
	@NotifyChange("mainUISet")
	public void changeUIState(@BindingParam("ui") VmMainUI mainUI) {
		mainUI.setEmbed(!mainUI.isEmbed());
	}

	public VmMainUI getSelected() {
		return selected;
	}

	public void setSelected(VmMainUI selected) {
		this.selected = selected;
	}

	@Override
	public VmMainUI getElementAt(int index) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getSize() {
		// TODO Auto-generated method stub
		return 0;
	}

}
